using UnityEngine;

namespace Crosstales.UI.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.UI.Util.FPSDisplay
    public class FPSDisplay : MonoBehaviour
    {
        // Fields
        public UnityEngine.UI.Text FPS;
        public int FrameUpdate;
        public UnityEngine.KeyCode Key;
        private float deltaTime;
        private float elapsedTime;
        private float msec;
        private float fps;
        private const string wait = "<i>...calculating <b>FPS</b>...</i>";
        private const string red = "<color=#E57373><b>FPS: {0:0.}</b> ({1:0.0} ms)</color>";
        private const string orange = "<color=#FFB74D><b>FPS: {0:0.}</b> ({1:0.0} ms)</color>";
        private const string green = "<color=#81C784><b>FPS: {0:0.}</b> ({1:0.0} ms)</color>";
        
        // Methods
        private void Update()
        {
            var val_17;
            UnityEngine.UI.Text val_18;
            object val_19;
            string val_20;
            var val_21;
            val_17 = this;
            if(this.Key != 0)
            {
                    if((UnityEngine.Input.GetKey(key:  this.Key)) == false)
            {
                goto label_2;
            }
            
            }
            
            float val_2 = UnityEngine.Time.deltaTime;
            val_2 = val_2 - this.deltaTime;
            val_2 = val_2 * 0.1f;
            val_2 = this.deltaTime + val_2;
            this.deltaTime = val_2;
            float val_3 = UnityEngine.Time.deltaTime;
            val_3 = this.elapsedTime + val_3;
            this.elapsedTime = val_3;
            if(val_3 <= 1f)
            {
                goto label_3;
            }
            
            int val_4 = UnityEngine.Time.frameCount;
            int val_15 = this.FrameUpdate;
            val_15 = val_4 - ((val_4 / val_15) * val_15);
            if(val_15 != 0)
            {
                    return;
            }
            
            this.FPS.enabled = true;
            float val_17 = this.deltaTime;
            float val_16 = 1000f;
            val_16 = val_17 * val_16;
            val_17 = 1f / val_17;
            this.msec = val_16;
            this.fps = val_17;
            if(val_17 >= 0)
            {
                goto label_6;
            }
            
            val_18 = this.FPS;
            val_19 = 536892547;
            val_20 = 27488592;
            goto label_11;
            label_3:
            val_17 = ???;
            val_21 = ???;
            goto typeof(UnityEngine.UI.Text).__il2cppRuntimeField_5E8;
            label_2:
            val_17 + 24.enabled = false;
            return;
            label_6:
            val_18 = this.FPS;
            if(val_17 < 0)
            {
                    val_19 = 536892547;
                val_20 = 27488600;
            }
            else
            {
                    val_19 = 536892547;
                val_20 = 27488584;
            }
            
            label_11:
            string val_14 = System.String.Format(format:  val_20, arg0:  val_19, arg1:  536892547);
        }
        public FPSDisplay()
        {
            this.FrameUpdate = 5;
        }
    
    }

}
